package com.pattern.singleton;

public class Captain2 {
    private Captain2() {
        System.out.println("A captain is elected for your team.");
    }

    //Bill Pugh solution
    private static class SingletonHelper {
        /*Nested class is referenced after getCaptain() is called*/
        private static final Captain2 captain = new Captain2();
    }

    public static Captain2 getCaptain() {
        return SingletonHelper.captain;
    }

}
